<%--                                                                       --%>
<%-- Copyright (c) 2001-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import =  "org.apache.commons.beanutils.PropertyUtils,
                    org.apache.struts.validator.DynaValidatorForm"
%>

<jsp:useBean id="packageGroupFindForm" type="com.broadvision.process.tools.action.ssppackage.PackageUserGroupForm" scope ="request"/>


<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<script language="JavaScript">

function doSearch(theForm) {
//  var theForm = document.packageGroupFindForm;
  theForm.editAction.value = "search";
  theForm.action = '<html:rewrite page="/bp/packageGroupFind.do"/>';
  theForm.submit();
  return false;
}

function doAddUserGroup(theForm, index) {
  var uA = "theForm.elements['searchResults[" + index + "].value'].value";
  var addId = eval(uA);
  theForm.addId.value = addId;
  theForm.action = '<html:rewrite page="/bp/packageGroupAdd.do"/>';
  theForm.submit();
  return false;
}

function doRemoveUserGroup(theForm, removeIndex) {
//  var theForm = document.packageGroupFindForm;
  theForm.editAction.value = "remove";
  theForm.removeIndex.value = removeIndex;
  theForm.action = '<html:rewrite page="/bp/packageGroupRemove.do"/>';
  theForm.submit();
  return false;
}


function doCancel(theForm) {
  theForm.action = '<html:rewrite page="/bp/packageView.do"/>';
  theForm.submit();
  return false;
}

function doSave(theForm) {
  var theForm = document.packageGroupFindForm;
  theForm.action = '<html:rewrite page="/bp/packageGroupSave.do"/>';
  return true;
}

</script>


<% 
  java.util.HashMap map = new java.util.HashMap();
  String packageId = request.getParameter("id"); 
  map.put("id", packageId);
  pageContext.setAttribute("pagetabParam", map, PageContext.PAGE_SCOPE);
%>

<!-- Zone 5 starts here.  -->
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message key="bp.package.contentArea" bundle="bp.messages"/>">
  <tr>
    <td valign="top" width="100%">		    
      <div class="pageTitle">
        <bean:write name="packageGroupFindForm" property="participantName"/>
      </div> 
			
      <!-- pageTab -->
      <div class="errorMessage"><html:errors bundle="bp.messages"/></div>
      <%@include file="/mc/common/pagetab.jsp" %>
      <!-- end of PageTab -->

<html:form action="/bp/packageGroupFind">

      <div class="pageButtonWrap">
        <b><bean:message key="bp.user.usersAndGroupsFind.label.search" bundle="bp.messages"/></b>&nbsp;
        <html:select property="findMode">
        <logic:equal name="packageGroupFindForm" property="usingFMLName" value="true">
          <html:option key="bp.user.usersAndGroupsFind.findMode.option.users" value="user" bundle="bp.messages"/>
        </logic:equal>
        <logic:notEqual name="packageGroupFindForm" property="usingFMLName" value="true">
          <html:option key="bp.user.usersAndGroupsFind.findMode.option.users.fullName" value="user" bundle="bp.messages"/>
        </logic:notEqual>
          <html:option key="bp.user.usersAndGroupsFind.findMode.option.groups" value="group" bundle="bp.messages"/>
        </html:select>&nbsp;:
        <html:text property="searchField" size="21" maxlength="80" />
        <html:submit property="gotoBtn" styleClass="inputButton">
          <bean:message key="button.goto" bundle="bp.messages"/>
        </html:submit>
      </div>


<html:hidden name="packageGroupFindForm" property="addId"/>
<html:hidden name="packageGroupFindForm" property="removeIndex"/>

<html:hidden name="packageGroupFindForm" property="id"/>
<html:hidden name="packageGroupFindForm" property="participantName"/>
<html:hidden name="packageGroupFindForm" property="forwardPage"/>
<html:hidden name="packageGroupFindForm" property="editAction"/>

      <!-- Start Result List here -->
      <% 
	int resultLength = 0;
//        int resultLength = packageGroupFindForm.get("searchResults").length;
      %>
      <bean:size id="resultSize" name="packageGroupFindForm"
property="searchResults" />

      <div class="pageSubtitle">
         <span class="left"><bean:message key="bp.user.usersAndGroupsFind.searchResult" arg0="<%=String.valueOf(resultSize.intValue())%>"  bundle="bp.messages"/></span>
         <span class="right">&nbsp;
         </span>
      </div> 

      <!-- Start List here -->
      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">

        <tr class="listHeader">
          <th id="Name" align="left"><bean:message key="bp.user.usersAndGroupsFind.header.name" bundle="bp.messages"/></th>
          <th id="LoginID" align="left">
            <logic:equal name="packageGroupFindForm"
property="findMode" value="user">
              <bean:message key="bp.user.usersAndGroupsFind.header.login" bundle="bp.messages"/>
            </logic:equal>
            <logic:notEqual name="packageGroupFindForm"
property="findMode" value="user">
              <bean:message key="bp.user.usersAndGroupsFind.header.groupId" bundle="bp.messages"/>
            </logic:notEqual>
          </th>
          <th id="Actions" align="left" nowrap><bean:message key="bp.user.usersAndGroupsFind.header.actions" bundle="bp.messages"/></th>
        </tr>

	<logic:equal name="resultSize" value="0">
           <tr class="listEven">
             <td colspan=4 align="center"><bean:message key="bp.user.usersAndGroupsFind.noMatch" bundle="bp.messages"/></td>
           </tr>
        </logic:equal>

	<logic:notEqual name="resultSize" value="0">
          <logic:iterate id="searchResults" name="packageGroupFindForm"
property="searchResults"
type="com.broadvision.ssp.client.PackageParticipant" indexId="i">

<html:hidden name="searchResults" property="name" indexed="true"/>
<html:hidden name="searchResults" property="value" indexed="true"/>


            <tr class="<%=i.intValue() % 2 == 0 ? "listEven" : "listOdd" %>">
              <td headers="Name"><bean:write name="searchResults" property="name"/></td>
              <td headers="LoginID"><bean:write name="searchResults" property="value"/></td>
              <td nowrap align="left" headers="Actions">
                <a href="#" onclick="doAddUserGroup(document.packageGroupFindForm,'<bean:write name="i" />');">
                   <img src="<%=request.getContextPath()%>/bp/images/action/icon_add.gif" border="0" alt='<bean:message key="image.alt.add" bundle="bp.messages"/>' title='<bean:message key="image.alt.add" bundle="bp.messages"/>' >
                </a>
              </td>
            </tr>
          </logic:iterate>
        </logic:notEqual>
      </table>

      <!--end result list here-->
			
      <div class="pageSubtitle">
        <span class="left"><bean:message key="bp.user.usersAndGroupsFind.usersAndGroups"  bundle="bp.messages"/></span>
        <span class="right">&nbsp;</span>
      </div> 

      <div class="pageInstructions">
        (*) <bean:message key="bp.package.detail.instruction" bundle="bp.messages"/>
      </div>
	
      <logic:equal name="packageGroupFindForm" property="removeLastOne" value="1">
        <div class="pageInstructions">
          <span class="errorMessage">
            <bean:message key="bp.package.detail.instruction.removeLastOne" bundle="bp.messages"/>
          </span>
        </div>
      </logic:equal>
	
      <!-- Start List here -->
      <table class="dataTable" border="0" cellspacing="1"
cellpadding="2" summary="Search result table" width="100%">
        <tr class="listHeader">
          <th id="Name" align="left"><bean:message key="bp.user.usersAndGroupsFind.header.name" bundle="bp.messages"/></th>
          <th id="LoginID" align="left"><bean:message key="bp.package.participantIdentities" bundle="bp.messages"/></th>
          <th id="Actions" align="left" nowrap><bean:message key="bp.user.usersAndGroupsFind.header.actions" bundle="bp.messages"/></th>
        </tr>

        <logic:iterate id="selectedUGs" name="packageGroupFindForm"
property="selectedUGs" indexId="removeIndex">

<html:hidden name="selectedUGs" property="name" indexed="true"/>
<html:hidden name="selectedUGs" property="value" indexed="true"/>
<html:hidden name="selectedUGs" property="valueType" indexed="true"/>
<html:hidden name="selectedUGs" property="valueValid" indexed="true"/>
<html:hidden name="selectedUGs" property="description" indexed="true"/>

          <tr class="<%=removeIndex.intValue() % 2 == 0 ? "listEven" : "listOdd" %>">
            <td headers="Name"><bean:write name="selectedUGs" property="name"/></td>
            <td headers="LoginID">
              <logic:equal name="selectedUGs" property="valueValid" value="0">
                 *
              </logic:equal>
              <bean:write name="selectedUGs" property="value"/>
            </td>
            <td nowrap align="left" headers="Actions">
              <a href="#" onclick="doRemoveUserGroup(document.packageGroupFindForm,'<bean:write name="removeIndex"/>');">
                <img src="<%=request.getContextPath()%>/bp/images/action/icon_remove.gif" border="0" alt='<bean:message key="image.alt.remove" bundle="bp.messages"/>' title='<bean:message key="image.alt.remove" bundle="bp.messages"/>' >
              </a>
            </td>
          </tr>
        </logic:iterate>
      </table>
      <!--end list here-->  
			
      <div class="pageButtonWrap" align="right">
        <html:button property="cancelBtn" styleClass="pageButton" onclick="javascript:doCancel(this.form);" >
          <bean:message key="button.cancel" bundle="bp.messages"/>
        </html:button>
        <html:submit property="saveBtn" styleClass="pageButton" onclick="javascript:doSave(this.form)">
           <bean:message key="button.save"  bundle="bp.messages"/>
        </html:submit>
      </div>
</html:form>
			
    </td>
  </tr>
</table>
<!--end zone 5 content here -->




